﻿using System;
using PostSharp.Laos;
using TestBat.IViewModels.Dialogs;
using TestBat.ServiceLocator;
using TestBat.ViewModels.Base.Commands;
using TestBat.ViewModels.Dialogs;

namespace TestBat.ViewModels.Attributes
{
    [Serializable]
    class YesNoDialogAttribute : OnMethodInvocationAspect
    {
        public YesNoDialogAttribute(string question)
        {
            this.question = question;
        }

        public override void OnInvocation(MethodInvocationEventArgs eventArgs)
        {
            DefaultServiceLocator.Get<IDialogMediator>().DialogViewModel = new YesNoDialogViewModel(question, new RelayCommand(e =>
            {
                eventArgs.Proceed();
            }), 
            new RelayCommand(e =>
            {
            }));
        }

        private readonly string question;
    }
}
